using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SaveUI : MonoBehaviour
{
    public GameObject panel;
    
    public bool canTalk;
    
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            canTalk = true;
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            panel.SetActive(false);
            canTalk = false;
        }
    }


    private void Update()
    {
        if (canTalk && Input.GetKeyDown(KeyCode.F))
        {
            panel.SetActive(true);
        }
    }


    public void SaveData()
    {
        SaveManager.Instance.SavePlayerData();
    }

    public void rest()
    {
        GameManager.Instance.playerStats.characterData.currentHealth =
            GameManager.Instance.playerStats.characterData.maxHealth;
        panel.SetActive(false);
    }
    
}
